package com.czk.utlls;

import com.alibaba.fastjson.JSONObject;
import com.czk.pojo.customer.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 客服消息
 *
 * @Author:ChenZhangKun
 * @Date: 2021/8/23 10:32
 */
@Component
public class CustomerServiceUtil {
    @Autowired
    private TokenUtil tokenUtil;
    private static String addCustomerUrl = "https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN";

    public void addCustomer() {
        //
        addCustomerUrl = addCustomerUrl.replace("ACCESS_TOKEN", tokenUtil.getToken().getAccessToken());
        //
        Customer customer = new Customer();
        customer.setKf_account("kevin");
        customer.setNickname("kd");
        customer.setPassword("durant");
        // 转为json
        String jsonString = JSONObject.toJSONString(customer);
        // 添加
        String post = WeChatUtil.post(addCustomerUrl, jsonString);
        System.out.println(post);
    }
}
